package com.regent.central.bill.core;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;
import java.util.Date;

@Table(name = "central_bill_sale_order_action_logging_style_sku")
public class SaleOrderActionLoggingStyleSKU {
    /**
     * 单据汇款动作记录变动货品SKU日志ID
     */
    @Id
    private String id;

    @Column(name = "central_bill_sale_order_action_logging_style_id")
    private String centralBillSaleOrderActionLoggingStyleId;

    /**
     * SKU ID
     */
    @Column(name = "sku_id")
    private String skuId;

    /**
     * 变动数量
     */
    @Column(name = "old_quantity")
    private BigDecimal oldQuantity;
    @Column(name = "new_quantity")
    private BigDecimal newQuantity;

    /**
     * 价格
     */
    @Column(name = "old_price")
    private BigDecimal oldPrice;
    @Column(name = "new_price")
    private BigDecimal newPrice;

    /**
     * 记录版本
     */
    private Integer version;

    /**
     * 创建时间
     */
    @Column(name = "date_created")
    private Date dateCreated;

    /**
     * 创建人员
     */
    @Column(name = "user_created")
    private String userCreated;

    /**
     * 最后更新时间
     */
    @Column(name = "last_updated")
    private Date lastUpdated;

    /**
     * 最后更新人员
     */
    @Column(name = "user_updated")
    private String userUpdated;

    /**
     * 删除时间
     */
    @Column(name = "time_deleted")
    private Long timeDeleted;

    /**
     * 删除人员
     */
    @Column(name = "user_deleted")
    private String userDeleted;

    public boolean modified() {
        return !oldQuantity.equals(newQuantity) || !oldPrice.equals(newPrice);
    }

    public BigDecimal total() {
        return newQuantity.subtract(oldQuantity);
    }

    public BigDecimal amount() {
        BigDecimal newAmount = newQuantity.multiply(newPrice);
        BigDecimal oldAmount = oldQuantity.multiply(oldPrice);
        return newAmount.subtract(oldAmount);
    }

    /**
     * 获取单据汇款动作记录变动货品SKU日志ID
     *
     * @return id - 单据汇款动作记录变动货品SKU日志ID
     */
    public String getId() {
        return id;
    }

    /**
     * 设置单据汇款动作记录变动货品SKU日志ID
     *
     * @param id 单据汇款动作记录变动货品SKU日志ID
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * @return central_bill_sale_order_action_logging_style_id
     */
    public String getCentralBillSaleOrderActionLoggingStyleId() {
        return centralBillSaleOrderActionLoggingStyleId;
    }

    /**
     * @param centralBillSaleOrderActionLoggingStyleId
     */
    public void setCentralBillSaleOrderActionLoggingStyleId(String centralBillSaleOrderActionLoggingStyleId) {
        this.centralBillSaleOrderActionLoggingStyleId = centralBillSaleOrderActionLoggingStyleId;
    }

    /**
     * 获取SKU ID
     *
     * @return sku_id - SKU ID
     */
    public String getSkuId() {
        return skuId;
    }

    /**
     * 设置SKU ID
     *
     * @param skuId SKU ID
     */
    public void setSkuId(String skuId) {
        this.skuId = skuId;
    }

    public BigDecimal getOldQuantity() {
        return oldQuantity;
    }

    public void setOldQuantity(BigDecimal oldQuantity) {
        this.oldQuantity = oldQuantity;
    }

    public BigDecimal getNewQuantity() {
        return newQuantity;
    }

    public void setNewQuantity(BigDecimal newQuantity) {
        this.newQuantity = newQuantity;
    }

    public BigDecimal getOldPrice() {
        return oldPrice;
    }

    public void setOldPrice(BigDecimal oldPrice) {
        this.oldPrice = oldPrice;
    }

    public BigDecimal getNewPrice() {
        return newPrice;
    }

    public void setNewPrice(BigDecimal newPrice) {
        this.newPrice = newPrice;
    }

    /**
     * 获取记录版本
     *
     * @return version - 记录版本
     */
    public Integer getVersion() {
        return version;
    }

    /**
     * 设置记录版本
     *
     * @param version 记录版本
     */
    public void setVersion(Integer version) {
        this.version = version;
    }

    /**
     * 获取创建时间
     *
     * @return date_created - 创建时间
     */
    public Date getDateCreated() {
        return dateCreated;
    }

    /**
     * 设置创建时间
     *
     * @param dateCreated 创建时间
     */
    public void setDateCreated(Date dateCreated) {
        this.dateCreated = dateCreated;
    }

    /**
     * 获取创建人员
     *
     * @return user_created - 创建人员
     */
    public String getUserCreated() {
        return userCreated;
    }

    /**
     * 设置创建人员
     *
     * @param userCreated 创建人员
     */
    public void setUserCreated(String userCreated) {
        this.userCreated = userCreated;
    }

    /**
     * 获取最后更新时间
     *
     * @return last_updated - 最后更新时间
     */
    public Date getLastUpdated() {
        return lastUpdated;
    }

    /**
     * 设置最后更新时间
     *
     * @param lastUpdated 最后更新时间
     */
    public void setLastUpdated(Date lastUpdated) {
        this.lastUpdated = lastUpdated;
    }

    /**
     * 获取最后更新人员
     *
     * @return user_updated - 最后更新人员
     */
    public String getUserUpdated() {
        return userUpdated;
    }

    /**
     * 设置最后更新人员
     *
     * @param userUpdated 最后更新人员
     */
    public void setUserUpdated(String userUpdated) {
        this.userUpdated = userUpdated;
    }

    /**
     * 获取删除时间
     *
     * @return time_deleted - 删除时间
     */
    public Long getTimeDeleted() {
        return timeDeleted;
    }

    /**
     * 设置删除时间
     *
     * @param timeDeleted 删除时间
     */
    public void setTimeDeleted(Long timeDeleted) {
        this.timeDeleted = timeDeleted;
    }

    /**
     * 获取删除人员
     *
     * @return user_deleted - 删除人员
     */
    public String getUserDeleted() {
        return userDeleted;
    }

    /**
     * 设置删除人员
     *
     * @param userDeleted 删除人员
     */
    public void setUserDeleted(String userDeleted) {
        this.userDeleted = userDeleted;
    }
}